const router = require('koa-router')()
router.prefix('/book')

const { bookImageInfo, AddbookInfo, getBooksInfo, getBookDetail,
    borrowBook, borrowList,borrowAllList,
    SearchBookByName,
    deleteBook,
    SearchBorrowByName} = require("../controller/book_controller");
const { verifyAuth } = require("../middleware/auth_middleware")
//获取borrow表信息
router.get("/borrow", verifyAuth, borrowList)
router.get("/borrowAll",verifyAuth,borrowAllList)
//获取书籍列表路由
router.get("/", getBooksInfo)
//搜索书籍路由
router.post("/search",SearchBookByName)
//获取书籍详情
router.get("/:id",getBookDetail)
//发布书籍
router.post("/",verifyAuth, AddbookInfo)
//获取书籍封面
router.get("/:bookId/image", bookImageInfo)
//删除书籍
router.delete("/:id",verifyAuth, deleteBook)
//借阅书籍borrow
router.post("/borrow", verifyAuth, borrowBook)
// 通过借阅人或发布人搜索借阅书籍
router.post("/borrow/search", verifyAuth, SearchBorrowByName)
module.exports=router